home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 5 / Gekikoh Dennoh Club Vol. 5 (Japan).7z / Gekikoh Dennoh Club Vol. 5 (Japan) (Track 01).bin / internet / webx / webxp040.lzh / Source / History.c < prev    next >
C/C++ Source or Header  |  1998-08-01  |  2KB  |  90 lines

  1. /* History.c */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <stdio.h>
  7. #include <sys/dos.h>
  8.  
  9.  
  10. extern unsigned short history_max;
  11.  
  12. /* ùÜù≡âeü[âuâïì\æóæ╠ */
  13. typedef struct _history_table {
  14.     int current_line;
  15.     char url[256];
  16.     char old_url[256];
  17. } HISTORY_TABLE;
  18.  
  19.  
  20. static HISTORY_TABLE *history_table;
  21. static short history_ptr = 0;
  22.  
  23. int InitHistory (void)
  24. {
  25.     short h;
  26.     if ((history_table = _dos_malloc (sizeof (HISTORY_TABLE) * history_max)) == NULL) {
  27.         printf ("üª âüâéâèé¬æ½éΦé▄é╣é±üiâqâXâgâèü[ùpé╠âüâéâèé¬èmò█é┼é½é▄é╣é±üj\n");
  28.         return(-1);
  29.     }
  30.     for (h = 0; h < history_max; h++)
  31.         *history_table[h].url = '\0';    /* ûóÄgùpé╔ */
  32.     return(0);
  33. }
  34.  
  35.  
  36. /* Éµô¬é╔âmü[âhé≡éPé┬Æ╟ë┴é╖éΘ */
  37. void AddHistory (char *url, char *old_url, int current_line)
  38. {
  39.     short h;
  40.     if ((old_url != NULL) && (!strcmp (url, old_url)))
  41.         return;
  42.  
  43.     for (h = 0; h < history_max; h++) {
  44.         if (!strcmp (history_table[h].url, url)) {    /* è∙é╔éáé┴é╜éτÆ╟ë┴é╡é╚éó */
  45.             history_table[h].current_line = current_line;
  46.             //printf("AddHistory() : %s, %d\n",history_table[h].url,history_table[h].current_line);
  47.             return;
  48.         }
  49.     }
  50.  
  51.     strcpy (history_table[history_ptr].url, url);
  52.     if (old_url == NULL) {
  53.         *history_table[history_ptr].old_url = '\0';
  54.     } else {
  55.         strcpy (history_table[history_ptr].old_url, old_url);
  56.     }
  57.     history_table[history_ptr].current_line = current_line;
  58.     if (++history_ptr >= history_max)
  59.         history_ptr = 0;
  60. }
  61.  
  62.  
  63. /* æOé╠é╠âmü[âhé≡ò╘é╖üiüuû▀éΘüvâ{â^âôÅêù¥üj */
  64. char *BeforeHistory (char *url,int *current_line)
  65. {
  66.     short h;
  67.  
  68.     //printf ("in %s\n", url);
  69.     *current_line = 0;
  70.     for (h = 0; h < history_max; h++) {
  71.         //printf ("history_table[%hd] = %s,%d\n", h, history_table[h].url,history_table[h].current_line);
  72.         if (!strcmp (history_table[h].url, url)) {
  73.             if (*history_table[h].old_url) {
  74.                 *current_line = history_table[h].current_line;
  75.                 return (history_table[h].old_url);
  76.             } else {
  77.                 break;
  78.             }
  79.         }
  80.     }
  81.     return (NULL);
  82. }
  83.  
  84.  
  85. /* Äƒé╠âmü[âhé≡ò╘é╖üiüuÉié▐üvâ{â^âôÅêù¥üj */
  86. char *NextHistory (void)
  87. {
  88.     return (NULL);        /* é▄é╛é╚éóé╔éσü[é± */
  89. }
  90.